/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newpackage;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Hishan
 */
public class Backup {

    public static void main(String[] args) {
//            System.out.println("mysqldump -uroot -p123456 kuru > "+System.getProperty("user.home")+"/abc.sql");
//            Process exec = Runtime.getRuntime().exec("mysqldump --opt -u root -p123456 kuru > "+System.getProperty("user.home")+"/abc.sql");
//            int waitFor = exec.waitFor();
//            if (waitFor==0) {
//                System.out.println("done");
//            } else {
//                System.out.println("wtf");
//            }
        Process p = null;
        try {
            Runtime runtime = Runtime.getRuntime();
            p = runtime.exec("mysqldump --routines -uroot -p123456 --add-drop-database -B kuru -r " + System.getProperty("user.home") + "/zxc.sql");
//change the dbpass and dbname with your dbpass and dbname
            int processComplete = p.waitFor();

            if (processComplete == 0) {

                System.out.println("Backup created successfully!");

            } else {
                System.out.println("Could not create the backup");
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
